<template>
  <footer class="footer">
    <!--  在 template 中访问所有数据都不需要加 this ，可加可不加 -->
    <span class="todo-count"
      >剩余<strong>{{ showList.length }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          href="javascript:;"
          @click="(isSel = 'all'), changeSel({ isSel })"
          :class="{ selected: isSel == 'all' }"
          >全部</a
        >
      </li>
      <li>
        <a
          href="javascript:;"
          @click="(isSel = 'no'), changeSel({ isSel })"
          :class="{ selected: isSel == 'no' }"
          >未完成</a
        >
      </li>
      <li>
        <a
          href="javascript:;"
          @click="(isSel = 'yes'), changeSel({ isSel })"
          :class="{ selected: isSel == 'yes' }"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="delAllDone">清除已完成</button>
  </footer>
</template>

<script>
import { mapState, mapMutations, mapGetters } from "vuex";
export default {
  props: [],
  data() {
    return {
      isSel: "all",
    };
  },
  computed: {
    ...mapState(["list"]),
    ...mapGetters(["showList"]),
  },
  methods: {
    ...mapMutations(["changeSel", "delAllDone"]),
  },
};
</script>